package com.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shop.mapper.ItemsCommentsMapper;
import com.shop.pojo.ItemsComments;
import com.shop.service.ItemsCommentsService;
import com.shop.vo.ItemsCommentsQueryRequest;
import com.shop.vo.ItemsCommentsSaveRequest;
import com.shop.vo.ItemsCommentsUpdateRequest;
import org.springframework.beans.BeanUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.metadata.IPage;



@Service("itemsCommentsService")
public class ItemsCommentsServiceImpl extends ServiceImpl<ItemsCommentsMapper, ItemsComments> implements ItemsCommentsService {

    @Override
    public IPage<ItemsComments> page(Page page, ItemsCommentsQueryRequest request){
        QueryWrapper<ItemsComments> wrapper = ItemsComments.queryWrapper(request);
        return this.page(page,wrapper);
    }

    @Transactional
    @Override
    public void save(ItemsCommentsSaveRequest request){
        ItemsComments itemsComments = new ItemsComments();
        BeanUtils.copyProperties(request,itemsComments);
        this.save(itemsComments);
    }

    @Transactional
    @Override
    public void update(ItemsCommentsUpdateRequest request){
        ItemsComments itemsComments = new ItemsComments();
        BeanUtils.copyProperties(request,itemsComments);
        this.updateById(itemsComments);
    }

    @Transactional
    @Override
    public void delete(String id){
        UpdateWrapper<ItemsComments> updateWrapper = new UpdateWrapper();
        this.update(updateWrapper);
    }

}